//
//  RecommendDetailHelper.m
//  JZMCFM
//
//  Created by zhangxin.com on 15/11/3.
//  Copyright (c) 2015年 陈卓. All rights reserved.
//

#import "RecommendDetailHelper.h"

@implementation RecommendDetailHelper

static RecommendDetailHelper *recommendetai = nil;
+(RecommendDetailHelper *)shareInstance
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        recommendetai = [[RecommendDetailHelper alloc]init];
        recommendetai.aoneArray = [NSMutableArray array];
    });
    return recommendetai;
    
}
//- (void)downLoadFinished:(void (^)())result;

//数据请求 ,结果回调
-(void)xiaobianTopRequestDataForReload
{
    
    
    
   // [self setUpDataUrl:UrlcomDeitail];
    
}
//-(void)jingpinTopRequestDataForReload
//{
//    [self setUpDataUrl:UrlcomDeitailTwo];
//}
//- (void)setUpDataUrl:(NSString *)urlStr
- (void)downLoadFinished:(void(^)())result
{

   dispatch_async(dispatch_get_global_queue(0, 0), ^{
        NSURL *url = [NSURL URLWithString:UrlcomDeitail];
        NSURLRequest *request = [NSURLRequest requestWithURL:url];
        [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
            NSMutableDictionary *recommendDetai = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];

            NSMutableArray *listArray = recommendDetai[@"list"];
            for (NSMutableDictionary *listdic in listArray) {
                RecommedTitleModel *model = [[RecommedTitleModel alloc]init];
                [model setValuesForKeysWithDictionary:listdic];
                [self.aoneArray addObject:model];
            }
            dispatch_async(dispatch_get_main_queue(), ^{
                result();
            });
            
        }];
        
        
    });
    
    
    
    
}
@end
